﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.IO;
using System.Reflection;    

namespace Treasures
{
    class ChipFigureBitmaps
    {
        #region Fields and Props

        public Bitmap[] FigureBitmaps { get; private set; }

        private string[] BitmapPathes { get; set; }

        private string path;

        #endregion

        #region Ctor
        public ChipFigureBitmaps(string[] _pathes)
        {
            BitmapPathes = _pathes;
            FigureBitmaps = new Bitmap[BitmapPathes.GetLength(0)];
            path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        }

        #endregion

        #region public methods

        public Bitmap this[int index]
        {
            get
            {
                if (FigureBitmaps[index] == null)
                {
                    FigureBitmaps[index] = new Bitmap(Path.Combine(path, BitmapPathes[index]));
                }
                return FigureBitmaps[index];
            }
            private set 
            {
                FigureBitmaps[index] = value;
            }
            
        }

        #endregion


    }

}
